﻿using delete.Common.Adapter;
using delete.Common.UserControls;
using delete.ViewModels;
using delete.Views;
using ModuleE.Views;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;
using System.Windows;
using System.Windows.Controls;

namespace delete
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }
        //设置默认首页ViewA
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            var regionManager = Container.Resolve<IRegionManager>();
            regionManager.RequestNavigate("ContentRegion", "ViewA");
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterForNavigation<ViewA>();
            containerRegistry.RegisterForNavigation<ViewB>();
            containerRegistry.RegisterForNavigation<ViewC>();
            containerRegistry.RegisterForNavigation<ViewD>();
            containerRegistry.RegisterForNavigation<ViewE>();

            containerRegistry.RegisterDialog<CloseDialog, CloseDialogViewModel>();
        }
        protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings)//初始化的过程中将区域适配器添加进去
        {
            base.ConfigureRegionAdapterMappings(regionAdapterMappings);
            regionAdapterMappings.RegisterMapping(typeof(StackPanel),Container.Resolve<StackPanelRegionAdapter>());//设置一个类型，从容器中取出适配器stackpanel
        }
        //关联其他模块
        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule<ModuleE.ModuleEModule>();
        }
    }
}
